maintainer="Michał Polański <michal@polanski.me>"
pkgname=llhttp
pkgver=9.2.1
pkgrel=0
pkgdesc="Port of http_parser to llparse"
url="https://llhttp.org/"
license="MIT"
arch="all"
makedepends="cmake clang npm"
subpackages="$pkgname-dev $pkgname-doc"
source="https://github.com/nodejs/llhttp/archive/v$pkgver/llhttp-$pkgver.tar.gz"

# secfixes:
#   9.2.1-r0:
#     - CVE-2024-27982

prepare() {
	default_prepare

	npm ci
}

build() {
	make release RELEASE="$pkgver"

	cmake -S release -B releasebuild \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBUILD_SHARED_LIBS=ON
	cmake --build releasebuild
}

check() {
	npm test
}

package() {
	DESTDIR="$pkgdir" cmake --install releasebuild

	install -Dm644 LICENSE-MIT "$pkgdir"/usr/share/doc/$pkgname/LICENSE
}

sha512sums="
653a0d65226644a7d71c538da343b2cff75bc7acc8cd6473ac19d166cc77c3e00c6a9087120d9abb63a9ac6b50e408c905d5925fa96d5d46d425ee7d0e3cdf9c  llhttp-9.2.1.tar.gz
"
